package com.powroznik.tracker.client.android;

import android.app.IntentService;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.util.Log;

public class TrackerService3 extends IntentService {
	public TrackerService3() {
		super("TS3");
	}

	@Override
	protected void onHandleIntent(Intent intent) {
		Log.w("TS3", "onHandleIntent");
		if (!bindService(new Intent(getBaseContext(), TrackerService1.class),
				new ServiceConnection() {
					public void onServiceConnected(ComponentName name,
							IBinder service) {
						try {
							((TrackerService1.TrackerService1Binder) service)
									.getService().trackLocations();
						} finally {
							unbindService(this);
						}
					}

					public void onServiceDisconnected(ComponentName name) {
					}
				}, Context.BIND_AUTO_CREATE)) {
			throw new RuntimeException();
		}
	}
}
